
<template>
<div id="table">

   <a-row >
     日期：
     <a-range-picker
       style="width: 210px"
       v-model="createTimeRange"
       format="YYYY-MM-DD"
       :placeholder="['开始时间', '结束时间']"
       @change="onDateChange"
       @ok="onDateOk"
     />
     单据类型
     <a-select default-value="1" style="width: 120px ;margin-right: 20px" @change="handleChange" @select="searchs">
       <a-select-option value="1" >
         报损单
       </a-select-option>
       <a-select-option value="2" >
         报溢单
       </a-select-option>
     </a-select>
     搜索
     <a-button type="primary" shape="circle" icon="search" @click="searchDamageList()"  />
   </a-row>
  <a-row >
    <a-col></a-col>
  </a-row>

  <a-table :data-source="resultList" rowkey="damageNumber" bordered @customRow="customRow">
    <a-table-column title="单号" data-index="damageNumber" />
    <a-table-column title="日期" data-index="damageDate" />
    <a-table-column title="类型" data-index="typeName" />
    <a-table-column title="操作员" data-index="trueName" />
    <a-table-column title="备注" data-index="remarks" />
  </a-table>
  <a-table :data-source="goodsList" rowkey="damageNumber" bordered >
    <a-table-column title="编号" data-index="damageNumber" />
    <a-table-column title="商品名称" data-index="damageDate" />
    <a-table-column title="商品型号" data-index="typeName" />
    <a-table-column title="单价" data-index="trueName" />
    <a-table-column title="数量" data-index="remarks" />
    <a-table-column title="单位" data-index="remarks" />
    <a-table-column title="总金额" data-index="remarks" />
  </a-table>


</div>
</template>
<script>

  import { axios } from '@/utils/request'
  import ATableColumn from "ant-design-vue/es/table/Column";
  import ACol from "ant-design-vue/es/grid/Col";
  import { Button } from 'ant-design-vue';
    export default {

      components: {ACol, ATableColumn},

      data(){
        return {
          customRow:(record,index)=>{
            console.log(record);
            return {
              on: {
                click: () => {
                  axios({
                    url:"http://127.0.0.1:8080/jeecg-boot/moreGoods/selelctById",
                    method: "get",
                    params:{
                      damagelistId:record.id
                    }

                  }).then((resp)=>{
                    this.resultList=resp;
                  })
                },
              }
            };
          },
          tagsFilterDropdownVisible: false,
          dateFormat: 'YYYY/MM/DD',
          pageNo:1,
          pageSize:3,
          resultList:[],
          beginTime:{},
          endTime:{},
          createTimeRange:[],
          mark:1,
          goodsList:[],

        };
      },
      methods: {
        handleChange(value) {
          console.log(`selected ${value}`);
        },
        onSearch(value) {
          console.log(value);
        },
        loadData(){

          axios({
            url:"http://127.0.0.1:8080/jeecg-boot/ssc/tdamageList/list1",
            method: "get",
          }).then((resp)=>{
            this.resultList=resp;
          })
        },
        searchDamageList(){
          if (this.mark==1){axios({
            url:"http://127.0.0.1:8080/jeecg-boot/ssc/tdamageList/list1/",
            method: "get",
            params:{
              beginTime:this.beginTime,
              endTime:this.endTime
            }

          }).then((resp)=>{
            this.resultList=resp;
          })}
          else if (this.mark==2){
            axios({
              url:"http://127.0.0.1:8080/jeecg-boot/more/list",
              method: "get",
              params:{
                beginTime:this.beginTime,
                endTime:this.endTime
              }

            }).then((resp)=>{
              this.resultList=resp;
            })
          }

        },
        onDateChange: function (value, dateString) {
          console.log(dateString[0],dateString[1]);
          this.beginTime=dateString[0];
          this.endTime=dateString[1];
        },
        onDateOk(value) {
          console.log(value);
        },
        searchs(a){
         this.mark = a;

        },



      },
      created(){
        this.loadData();
      }
      ,
      mounted(){

      },




    }
</script>

<style scoped>

</style>